<?php

use yii\helpers\Url;
use yii\helpers\Html;
use backend\models\Menu;
use kartik\editable\Editable;

return [
    [
        'class' => 'kartik\grid\CheckboxColumn',
        'width' => '20px',
    ],
    [
        'class' => 'kartik\grid\SerialColumn',
        'width' => '30px',
    ],
    // [
    // 'class'=>'\kartik\grid\DataColumn',
    // 'attribute'=>'id',
    // ],
    [
        'class' => '\kartik\grid\DataColumn',
        'attribute' => 'name',
        'format' => 'raw',
        'value' => function($model) {
            if (Menu::subMenu($model->id)) {
                return Html::a($model->name, Url::current(['parent' => $model->id]));
            } else {
                return $model->name;
            }
        }
    ],
    [
        'class' => '\kartik\grid\DataColumn',
        'attribute' => 'route',
    ],
    [
        'class' => '\kartik\grid\EditableColumn',
        'attribute' => 'order',
        'editableOptions' => [
            'inputType' => Editable::INPUT_SPIN,
            'formOptions' => ['action' => ['change-value']],
            'options' => [
                'pluginOptions' => ['min' => 0, 'max' => 5000]
            ]
        ],
    ],
    // [
    // 'class'=>'\kartik\grid\DataColumn',
    // 'attribute'=>'type',
    // ],
    [
        'class' => 'kartik\grid\ActionColumn',
        'dropdown' => false,
        'vAlign' => 'middle',
        'urlCreator' => function($action, $model, $key, $index) {
            return Url::to([$action, 'id' => $key]);
        },
        'viewOptions' => ['role' => 'modal-remote', 'title' => Yii::t('common', 'View'), 'data-toggle' => 'tooltip'],
        'updateOptions' => ['data-pjax' => '0', 'title' => Yii::t('common', 'Update'), 'data-toggle' => 'tooltip'],
        'deleteOptions' => ['role' => 'modal-remote', 'title' => Yii::t('common', 'Delete'),
            'data-confirm' => false, 'data-method' => false, // for overide yii data api
            'data-request-method' => 'post',
            'data-toggle' => 'tooltip',
            'data-confirm-title' => Yii::t('common', 'Are you sure?'),
            'data-confirm-message' => Yii::t('common', 'Are you sure want to delete this item')],
    ],
];
